/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

/**
 * @version queue.h 0.0.2
 * @package Comoro
 * @author Dr.NP <np@bsgroup.org>
 *
 * Event queue header
 */

#include <time.h>

#include "event.h"
#include "lua.h"

// Constants
#define BASE_QUEUE_EVENT						1024
#define MAX_FUNC_LENGTH						256
#define CLOCK_CB_FUNC_POOL_SIZE				256

// Clock callback function list
struct clock_cb_func
{
	void (*fn) (void *);
	void *arg;
};

// Event struct
struct event_item
{
	int item_id;
	time_t start_time;
	int loop;
	int interval;
	lua_State *state;
	int client_id;
	char func[MAX_FUNC_LENGTH];
	char **params;
	int plen;
};

/* BEGIN OF FUNCTION */
int queue_init									();
void queue_clear									();
void queue_timer_cb								(void *);
int queue_add_item								(int, int, lua_State *, int, char *, char **, int);
void queue_del_item								(int);
int queue_clock_cb_func_add						(void (*) (void *), void *);
int queue_clock_cb_func_del						(void (*) (void *));
void queue_clock_handler							(int, short, void *);
void queue_clock_callback						();
/* END OF FUNCTION */
